<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Xrfg\Api\Consume\Console\ConsumeConsole;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        ConsumeConsole::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // 日志文件写入权限修改
        // $schedule->call(function () {
        //     shell_exec('chmod -R 777 /www/wwwroot/xg-server/storage');
        // })->everyMinute();
//         // 获取USDT对人民币价格
//         //        $schedule->command('cny usdt')->everyFiveMinutes();
//         // 兑换价格每分钟更新
//         $schedule->command('et_price')->everyMinute();
//         // 提现
//         $schedule->command('withdraw')->everyMinute();
//         // 抢U订单结算
//         $schedule->command('giveu')->everyMinute();
//         // 每天0点更新用户等级
//         $schedule->command('UpdateAllLevel')->daily();
//         // 每天0:05结算团队收益
//         $schedule->command('leader')->dailyAt('0:05');
//         // 每天0:10结算抢U获得YTB收益
//         $schedule->command('release-static')->dailyAt('0:10');


//         // 获取USDT、BTC对人民币价格
// //        $schedule->command('cny')->everyFiveMinutes();
//         // 重新构建订单簿，防止订单写入失败
//         $schedule->command('orderbook:rebuild')->everyMinute();

//         // 1m
//         $schedule->command('kline 1')->everyMinute();
//         // 5m
//         $schedule->command('kline 5')->everyFiveMinutes();
//         // 15m
//         $schedule->command('kline 15')->everyFifteenMinutes();
//         // 30m
//         $schedule->command('kline 30')->everyThirtyMinutes();
//         // 1h
//         $schedule->command('kline 60')->hourly();
//         // 4h
//         $schedule->command('kline 240')->when(function () {
//             return in_array(now()->hour, [0, 4, 8, 12, 16, 20]) && now()->minute === 0;
//         });
//         // 1d
//         $schedule->command('kline 1440')->daily();
//         // 1w
//         $schedule->command('kline 10080')->weekly();

        // 每日0:02收益结算
        // $schedule->command('daily_revenue')->dailyAt('0:02');
        $schedule->command('daily_revenue')->everyMinute();
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__ . '/Commands');

        require base_path('routes/console.php');
    }
}
